Proximity API multiplayer networked game sample


Windows Runtime
proximity, multi-player game
Windows RT
en-US
11/25/2013

This sample demonstrates key network techniques for multi-player games, including initiating handshake (with the Proximity API) and communicating. It also demonstrates the minimum requirements to create a network connection in games.

You can use the Proximity (PeerFinder) API to set up a socket connection between the same application across multiple computers. The application is a simple, multi-player game, which demonstrates how to use the Proximity API to create a socket connection between peer apps on multiple computers using a tap gesture or by browsing using a wireless radio.

In order to see the multi-player scenario, this sample must be run on two computers. For scenarios that use a tap gesture, each computer must have a proximity device installed. For scenarios that use wireless browsing, each computer must have a wireless device that supports Wi-Fi Direct installed. If you don't have hardware that supports proximity tapping such as Near-Field Communication (NFC) radio, you can use the proximity driver sample that is part of the Windows Driver Kit (WDK) samples. You can use the sample driver to simulate a tap gesture over a network connection between two computers. For information on how to download the WDK, see Windows Driver Kit (WDK). After you have installed the WDK and samples, you can find the proximity driver sample in the src\nfp directory in the location where you installed the WDK samples. See the NetNfpProvider.html file in the src\nfp\net directory for instructions on building and running the simulator. After you start the simulator, it runs in the background while your proximity app is running in the foreground. Your app must be in the foreground for the tap simulation to work.

Playing the game

The Critter Stomp game requires players to tap as many critters on the screen as possible within a period of time. This game can be played by one player, or by up to six players simultaneously to compete with each other.

  • For single player: After launching the game, click STOMP alone to start the game.
  • For two players: After launching the game, both players click STOMP with friends. In the next page, one player (the client player) clicks Join a game, and the other (the host player) clicks Host a game. The host player sees and clicks the name of the client player to send out an invitation. The client player sees and clicks the name of the host player to accept that invitation. The host player sees the accept response from the client player, then clicks Start Game to start the game.
  • For two players with NFC-capable devices: After launching the game, both players click STOMP with friends. In the next page, one player (the client player) clicks Join a game, and the other (the host player) clicks Host a game. Two players tap their devices around the NFC modules to initiate connection. The host player sees two devices connected, then clicks Start Game to start the game.
  • For three to six players: There is one and only one host player, and this player is required to connect one client player after another using either of the connection methods above. The host player starts the game with currently connected client players by clicking Start Game.

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.

Note  For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft Visual Studio 2012.

Related topics

Build 2013 Talk: Play Together! Leaderboards with Windows Azure and Multiplayer with Wi-Fi Direct
Quickstart: Connecting apps using tapping or browsing (JavaScript)
Quickstart: Connecting apps using tapping or browsing (C#)
Guidelines for developing using proximity
Windows.Networking.Proximity
Windows app samples

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2

Build the sample

  1. Start Visual Studio 2013 and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio 2013 Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample.

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.